this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.Ui=this.BX.Landing.Ui||{};this.BX.Landing.Ui.Panel=this.BX.Landing.Ui.Panel||{};this.BX.Landing.Ui.Panel.Formsettingspanel=this.BX.Landing.Ui.Panel.Formsettingspanel||{};(function(e,t,n,i,r,o,a,s,l,u,d,c,p,g,y,f,v){"use strict";var h=function e(){babelHelpers.classCallCheck(this,e)};babelHelpers.defineProperty(h,"TYPE_0",0);babelHelpers.defineProperty(h,"TYPE_1",1);babelHelpers.defineProperty(h,"TYPE_2",2);var b,m,L;function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var C={removable:true,draggable:false,color:"blue"};var O=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this));n.setEventNamespace("BX.Landing.UI.Field.RuleField.FieldElement");n.subscribeFromOptions(y.fetchEventsFromOptions(e));n.options=T(T({},C),e);n.cache=new g.Cache.MemoryCache;return n}babelHelpers.createClass(t,[{key:"getDragButtonLayout",value:function e(){return this.cache.remember("dragButton",(function(){var e=new s.IconButton({type:s.IconButton.Types.drag,style:{width:"20px"}});return e.getLayout()}))}},{key:"getActionsDropdown",value:function e(){var t=this;return this.cache.remember("actionsDropdown",(function(){var e=new window.top.BX.Landing.UI.Field.DropdownInline({title:t.options.actionsLabel,items:t.options.actionsList,content:t.options.actionsValue});e.subscribe("onChange",(function(){t.emit("onChange")}));return e}))}},{key:"getActionsLayout",value:function e(){var t=this;return this.cache.remember("actionsLayout",(function(){return g.Tag.render(b||(b=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-field-element-text-action">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t"])),t.getActionsDropdown().getLayout())}))}},{key:"getTitleLayout",value:function e(){var t=this;return this.cache.remember("titleLayout",(function(){return g.Tag.render(m||(m=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-field-element-text-title">',"</div>"])),g.Text.encode(t.options.title))}))}},{key:"getRemoveButtonLayout",value:function e(){var t=this;return this.cache.remember("removeButton",(function(){var e=new s.IconButton({type:s.IconButton.Types.remove,onClick:function e(){return t.emit("onRemove")},iconSize:"9px",style:{width:"20px",marginLeft:"auto"}});return e.getLayout()}))}},{key:"getLayout",value:function e(){var t=this;return this.cache.remember("layout",(function(){return g.Tag.render(L||(L=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div\n\t\t\t\t\tclass="landing-ui-field-element-','"\n\t\t\t\t\tdata-field-id="','"\n\t\t\t\t>\n\t\t\t\t\t','\n\t\t\t\t\t<div class="landing-ui-field-element-text">\n\t\t\t\t\t\t',"\n\t\t\t\t\t\t","\n\t\t\t\t\t</div>\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),t.options.color,g.Text.encode(t.options.id),t.options.draggable?t.getDragButtonLayout():"",t.options.actionsLabel?t.getActionsLayout():"",t.getTitleLayout(),t.options.removable?t.getRemoveButtonLayout():"")}))}}]);return t}(p.EventEmitter);babelHelpers.defineProperty(O,"Colors",{blue:"blue",green:"green",red:"red"});var I,P,_,F,D;function A(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?A(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var R=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),"cache",new g.Cache.MemoryCache);n.setEventNamespace("BX.Landing.UI.Panel.FormSettingsPanel.ValueElement");n.options=k({},e);n.state=k({},n.options.data);return n}babelHelpers.createClass(t,[{key:"getOperatorLabelLayout",value:function e(){var t=this;return this.cache.remember("operatorLabelLayout",(function(){var e=t.getOperatorLabelText(t.options.data.operation);return g.Tag.render(I||(I=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div\n\t\t\t\t\tclass="landing-ui-rule-value-operator-label"\n\t\t\t\t\tonclick="','"\n\t\t\t\t>',"</div>\n\t\t\t"])),t.onOperatorLabelClick.bind(t),e)}))}},{key:"onOperatorLabelClick",value:function e(t){t.preventDefault();this.getOperatorSettingsPopup().show()}},{key:"getTargetContainer",value:function e(){var t=this;return this.cache.remember("targetContainer",(function(){return t.getLayout().closest(".landing-ui-panel-content-body-content")||t.getLayout()}))}},{key:"getOperatorSettingsPopup",value:function e(){var t=this;return this.cache.remember("operatorSettingsPopup",(function(){var e=u.PageObject.getRootWindow();return new e.BX.Main.Popup({bindElement:t.getLayout(),targetContainer:t.getTargetContainer(),content:t.getOperatorField().getLayout(),autoHide:true,minWidth:160,offsetLeft:20,offsetTop:3,bindOptions:{position:"bottom"}})}))}},{key:"getValueLabelLayout",value:function e(){var t=this;return this.cache.remember("valueLabelLayout",(function(){var e=t.getValueLabelText(t.options.data.value);var n=g.Tag.render(P||(P=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div\n\t\t\t\t\tclass="landing-ui-rule-value-value-label"\n\t\t\t\t\tonclick="','"\n\t\t\t\t>\n\t\t\t\t\t<span class="landing-ui-rule-value-value-label-inner">',"</span>\n\t\t\t\t</div>\n\t\t\t"])),t.onValueLabelClick.bind(t),g.Text.encode(e));if(t.options.data.operation==="any"||t.options.data.operation==="empty"){g.Dom.hide(n)}return n}))}},{key:"setValueLabelText",value:function e(t){this.getValueLabelLayout().firstElementChild.textContent=t}},{key:"onValueLabelClick",value:function e(t){t.preventDefault();this.getValueSettingsPopup().show()}},{key:"getValueSettingsPopup",value:function e(){var t=this;return this.cache.remember("valueSettingsPopup",(function(){var e=u.PageObject.getRootWindow();var n=g.Tag.render(_||(_=babelHelpers.taggedTemplateLiteral(['<div class="value-settings-popup"></div>'])));var i=g.Text.getRandom();var r=t.getTargetField();if(r.type==="list"||r.type==="product"||r.type==="checkbox"||r.type==="radio"||r.type==="bool"){var o=function(){if(r.type==="bool"){return[{label:v.Loc.getMessage("LANDING_RULE_FIELD_CONDITION_VALUE_YES"),value:"Y"},{label:v.Loc.getMessage("LANDING_RULE_FIELD_CONDITION_VALUE_NO"),value:"N"}]}return r.items}();o.forEach((function(e){var o=String(r.value)===String(e.value);g.Dom.append(g.Dom.append(t.renderValueRadioButton(k(k({},e),{},{id:i,checked:o})),n),n)}))}else{var a=function(){if(g.Type.isStringFilled(t.options.data.value)){return t.getValueLabelText(t.options.data.value)}return""}();var s=new d.TextField({textOnly:true,onValueChange:function e(){var n=s.getValue()||v.Loc.getMessage("LANDING_RULE_CONDITION_VALUE_EMPTY_MSGVER_1");t.setValueLabelText(n);t.state.value=s.getValue();t.emit("onChange")},content:a});g.Dom.append(s.getLayout(),n)}return new e.BX.Main.Popup({bindElement:t.getLayout(),targetContainer:t.getTargetContainer(),content:n,width:228,autoHide:true,maxHeight:200,offsetLeft:20,offsetTop:3,events:{onShow:function e(){g.Dom.addClass(t.getLayout(),"landing-ui-rule-value-active")},onClose:function e(){g.Dom.removeClass(t.getLayout(),"landing-ui-rule-value-active")}}})}))}},{key:"renderValueRadioButton",value:function e(t){var n=this;var i=t.label,r=t.value,o=t.id,a=t.checked;var s=function e(){n.setValueLabelText(i);n.state.value=r;n.emit("onChange")};return g.Tag.render(F||(F=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="value-settings-item value-settings-item-value">\n\t\t\t\t<input\n\t\t\t\t\ttype="radio"\n\t\t\t\t\tid="value_',"_",'"\n\t\t\t\t\tname="value_',"_",'"\n\t\t\t\t\tonchange="','"\n\t\t\t\t\t','\n\t\t\t\t>\n\t\t\t\t<label for="value_',"_",'">',"</label>\n\t\t\t</div>\n\t\t"])),o,r,o,this.options.data.target,s,a?"checked":"",o,r,g.Text.encode(i))}},{key:"getOperatorField",value:function e(){var t=this;return this.cache.remember("operatorField",(function(){var e=t.options.dictionary.deps.condition;var n=t.getTargetField();return new BX.Landing.UI.Field.Radio({selector:"operation",value:[t.state.operation],items:e.operations.filter((function(e){return(!g.Type.isArrayFilled(e.fieldTypes)||e.fieldTypes.includes(n.type))&&(!g.Type.isArrayFilled(e.excludeFieldTypes)||g.Type.isArrayFilled(e.excludeFieldTypes)&&!e.excludeFieldTypes.includes(n.type))})).map((function(e){return{name:e.name,value:e.id}})),onChange:t.onOperationChange.bind(t)})}))}},{key:"setOperationLabelText",value:function e(t){this.getOperatorLabelLayout().textContent=t}},{key:"onOperationChange",value:function e(){var t=this.getOperatorField();var n=t.getValue(),i=babelHelpers.slicedToArray(n,1),r=i[0];if(r==="empty"||r==="any"){g.Dom.hide(this.getValueLabelLayout())}else{g.Dom.show(this.getValueLabelLayout())}this.setOperationLabelText(this.getOperatorLabelText(r));this.state.operation=r;this.emit("onChange")}},{key:"getRemoveButton",value:function e(){var t=this;return this.cache.remember("removeButton",(function(){return new s.IconButton({type:s.IconButton.Types.remove,iconSize:"9px",style:{width:"19px",marginLeft:"auto"},onClick:function e(){t.emit("onRemove");t.emit("onChange")}})}))}},{key:"getLayout",value:function e(){var t=this;return this.cache.remember("layout",(function(){return g.Tag.render(D||(D=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div\n\t\t\t\t\tclass="landing-ui-rule-value"\n\t\t\t\t\tdata-target="','"\n\t\t\t\t>\n\t\t\t\t\t<div class="landing-ui-rule-value-text">\n\t\t\t\t\t\t',"\n\t\t\t\t\t\t",'\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="landing-ui-rule-value-actions">\n\t\t\t\t\t\t','\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="landing-ui-rule-decoration">\n\t\t\t\t\t\t<div class="landing-ui-rule-decoration-v-line"></div>\n\t\t\t\t\t\t<div class="landing-ui-rule-decoration-h-line"></div>\n\t\t\t\t\t\t<div class="landing-ui-rule-decoration-arrow"></div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t'])),g.Text.encode(t.options.data.target),t.getOperatorLabelLayout(),t.getValueLabelLayout(),t.options.removable?t.getRemoveButton().getLayout():"")}))}},{key:"getOperatorLabelText",value:function e(t){return this.options.dictionary.deps.condition.operations.reduce((function(e,n){if(n.id===t){return n.name}return e}),this.options.dictionary.deps.condition.operations[0].name)}},{key:"getTargetField",value:function e(){var t=this;return this.cache.remember("targetField",(function(){return t.options.fields.find((function(e){return String(e.id)===String(t.options.data.target)}))}))}},{key:"getValueLabelText",value:function e(t){var n=this.getTargetField();if(g.Type.isPlainObject(n)){if(g.Type.isArrayFilled(n.items)){var i=n.items.find((function(e){return String(e.value)===String(t)}));if(g.Type.isPlainObject(i)){return i.label}}if(g.Type.isStringFilled(t)){if(t==="Y"){return v.Loc.getMessage("LANDING_RULE_CONDITION_VALUE_YES")}if(t==="N"){return v.Loc.getMessage("LANDING_RULE_CONDITION_VALUE_NO")}return t}}return v.Loc.getMessage("LANDING_RULE_CONDITION_VALUE_EMPTY_MSGVER_1")}},{key:"getValue",value:function e(){return k({},this.state)}}]);return t}(p.EventEmitter);var H;function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var S=function(){function e(t){babelHelpers.classCallCheck(this,e);babelHelpers.defineProperty(this,"cache",new g.Cache.MemoryCache);this.options=N({},t)}babelHelpers.createClass(e,[{key:"getLayout",value:function e(){var t=this;return this.cache.remember("layout",(function(){return g.Tag.render(H||(H=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-entry-type-separator">\n\t\t\t\t\t<div class="landing-ui-rule-entry-type-separator-inner">\n\t\t\t\t\t\t',"\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t"])),t.getSeparatorLabel())}))}},{key:"getSeparatorLabel",value:function e(){if(String(this.options.typeId)===String(2)){return v.Loc.getMessage("LANDING_RULE_TYPE_SEPARATOR_TYPE_2")}return v.Loc.getMessage("LANDING_RULE_TYPE_SEPARATOR_TYPE_1")}}]);return e}();var x,B,j,U,M;function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?V(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var G=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),"conditions",[]);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),"expressions",[]);n.setEventNamespace("BX.Landing.UI.Panel.FormSettingsPanel.RuleEntry");n.options=X({enableHeader:true,expressions:[]},e);n.cache=new g.Cache.MemoryCache;n.onConditionFieldValueRemove=n.onConditionFieldValueRemove.bind(babelHelpers.assertThisInitialized(n));n.onConditionFieldRemove=n.onConditionFieldRemove.bind(babelHelpers.assertThisInitialized(n));if(g.Type.isArrayFilled(n.options.conditions)){n.options.conditions.forEach((function(e){n.addCondition(e)}));n.options.expressions.forEach((function(e){n.addExpression(e)}))}return n}babelHelpers.createClass(t,[{key:"getConditionsLayout",value:function e(){return this.cache.remember("conditionsLayout",(function(){return g.Tag.render(x||(x=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-entry-conditions"></div>\n\t\t\t'])))}))}},{key:"getExpressionsLayout",value:function e(){var t=this;return this.cache.remember("expressionsLayout",(function(){return g.Tag.render(B||(B=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-entry-expressions">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t"])),t.getAddExpresionFieldLinkLayout())}))}},{key:"getHeaderLayout",value:function e(){return this.cache.remember("headerLayout",(function(){return g.Tag.render(j||(j=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-entry-header">',"</div>\n\t\t\t"])),v.Loc.getMessage("LANDING_RULE_ENTRY_HEADER"))}))}},{key:"getLayout",value:function e(){var t=this;return this.cache.remember("layout",(function(){return g.Tag.render(U||(U=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-entry">\n\t\t\t\t\t','\n\t\t\t\t\t<div class="landing-ui-rule-entry-body">\n\t\t\t\t\t\t',"\n\t\t\t\t\t\t","\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t"])),t.options.enableHeader?t.getHeaderLayout():"",t.getConditionsLayout(),t.getExpressionsLayout())}))}},{key:"onConditionFieldRemove",value:function e(t){var n=t.getTarget();var i=n.getLayout();this.conditions=this.conditions.filter((function(e){return e!==n}));var r=i.nextElementSibling;while(g.Type.isDomNode(r)&&!r.matches('[class*="landing-ui-field-element"]')){this.conditions=this.conditions.filter((function(e){return e.getLayout()!==r}));g.Dom.remove(r);r=i.nextElementSibling}if(!g.Type.isDomNode(r)){var o=i.previousElementSibling;if(g.Type.isDomNode(o)&&g.Dom.hasClass(o,"landing-ui-rule-entry-type-separator")){g.Dom.remove(o)}}g.Dom.remove(i);this.emit("onChange")}},{key:"onConditionFieldValueRemove",value:function e(t){var n=t.getTarget();var i=n.getLayout();this.conditions=this.conditions.filter((function(e){return e!==n}));if(g.Dom.hasClass(i.nextElementSibling,"landing-ui-rule-entry-type-separator")){g.Dom.remove(i.nextElementSibling)}else if(g.Dom.hasClass(i.previousElementSibling,"landing-ui-rule-entry-type-separator")){g.Dom.remove(i.previousElementSibling)}g.Dom.remove(i)}},{key:"addCondition",value:function e(t){var n=this;if(!this.conditions.includes(t)){this.conditions.push(t);if(t instanceof R){t.subscribe("onRemove",this.onConditionFieldValueRemove);t.subscribe("onChange",(function(){return n.emit("onChange")}));var i=babelHelpers.toConsumableArray(this.getConditionsLayout().childNodes);var r=i.reduce((function(e,n){if(g.Dom.hasClass(n,"landing-ui-rule-value")&&String(g.Dom.attr(n,"data-target"))===String(t.options.data.target)||n.matches('[class*="landing-ui-field-element"]')&&String(g.Dom.attr(n,"data-field-id"))===String(t.options.data.target)){return n}return e}),null);if(g.Type.isDomNode(r)){g.Dom.insertAfter(t.getLayout(),r);if(g.Dom.hasClass(r,"landing-ui-rule-value")){var o=new S({typeId:this.options.typeId});g.Dom.insertBefore(o.getLayout(),t.getLayout())}return}}if(t instanceof O){t.subscribe("onRemove",this.onConditionFieldRemove);t.subscribe("onChange",(function(){return n.emit("onChange")}));if(babelHelpers.toConsumableArray(this.getConditionsLayout().childNodes).length>0){var a=new S({typeId:this.options.typeId});g.Dom.append(a.getLayout(),this.getConditionsLayout())}}g.Dom.append(t.getLayout(),this.getConditionsLayout());this.emit("onChange")}}},{key:"getExpressionActionPanel",value:function e(){var t=this;return this.cache.remember("expressionActionPanel",(function(){return new f.ActionPanel({left:[{id:"addField",text:v.Loc.getMessage("LANDING_RULE_ENTRY_ADD_FIELD_LABEL"),onClick:t.onAddExpressionFieldClick.bind(t)}]})}))}},{key:"onAddExpressionFieldClick",value:function e(t){var n=this;t.preventDefault();var i=this.getFieldsListMenu();i.getMenuItems().forEach((function(e){var t=n.expressions.some((function(t){return String(t.options.id)===String(e.getId())}));if(t){g.Dom.addClass(e.getLayout().item,"landing-ui-disabled")}else{g.Dom.removeClass(e.getLayout().item,"landing-ui-disabled")}}));this.getFieldsListMenu().show()}},{key:"getExpressionAllowedFieldsList",value:function e(){var t=this;var n=["page","layout"];return this.options.fields.filter((function(e){if(!n.includes(e.type)){return!t.conditions.find((function(t){return g.Type.isPlainObject(t.options)&&(g.Type.isPlainObject(t.options.data)&&String(t.options.data.target)===String(e.id)||String(t.options.id)===String(e.id))}))}return true}))}},{key:"getFieldsListMenu",value:function e(){var t=this;return this.cache.remember("fieldsListMenu",(function(){return new window.top.BX.Main.Menu({bindElement:t.getExpressionActionPanel().getLayout(),maxHeight:205,items:t.getExpressionAllowedFieldsList().map((function(e){return{id:e.id,text:e.label,onclick:t.onAddExpressionField.bind(t,e)}}))})}))}},{key:"getAddExpresionFieldLinkLayout",value:function e(){var t=this;return this.cache.remember("addExpressionFieldLinkLayout",(function(){return g.Tag.render(M||(M=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-entry-add-expression-field-link">\n\t\t\t\t\t<div class="landing-ui-rule-entry-add-expression-field-link-action-panel">\n\t\t\t\t\t\t','\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="landing-ui-rule-entry-add-expression-field-link-separator"></div>\n\t\t\t\t</div>\n\t\t\t'])),t.getExpressionActionPanel().getLayout())}))}},{key:"onAddExpressionField",value:function e(t){var n=new O({id:t.id,title:t.label,removable:true,color:O.Colors.green,actionsLabel:v.Loc.getMessage("LANDING_RULE_EXPRESSION_FIELD_ACTION_LABEL"),actionsList:[{name:v.Loc.getMessage("LANDING_RULE_EXPRESSION_FIELD_ACTION_SHOW_LABEL"),value:"show"},{name:v.Loc.getMessage("LANDING_RULE_EXPRESSION_FIELD_ACTION_HIDE_LABEL"),value:"hide"}],actionsValue:"show"});this.addExpression(n);this.getFieldsListMenu().close();this.emit("onChange")}},{key:"onExpressionFieldRemove",value:function e(t){var n=t.getTarget();g.Dom.remove(n.getLayout());this.expressions=this.expressions.filter((function(e){return String(e.options.id)!==String(n.options.id)}));this.adjustExpressionFieldsZIndexes();this.emit("onChange")}},{key:"onExpressionFieldChange",value:function e(){this.emit("onChange")}},{key:"adjustExpressionFieldsZIndexes",value:function e(){babelHelpers.toConsumableArray(this.getExpressionsLayout().children).reverse().forEach((function(e,t){if(e.matches('[class*="landing-ui-field-element"]')){g.Dom.style(e,"z-index",t+2)}}))}},{key:"addExpression",value:function e(t){if(!this.expressions.includes(t)){this.expressions.push(t);t.subscribe("onRemove",this.onExpressionFieldRemove.bind(this));t.subscribe("onChange",this.onExpressionFieldChange.bind(this));void this.getLayout();g.Dom.insertBefore(t.getLayout(),this.getAddExpresionFieldLinkLayout());this.adjustExpressionFieldsZIndexes()}}},{key:"getValue",value:function e(){var t=this;return this.conditions.filter((function(e){return e instanceof R})).reduce((function(e,n){return[].concat(babelHelpers.toConsumableArray(e),babelHelpers.toConsumableArray(t.expressions.map((function(e){return{condition:X(X({},n.getValue()),{},{event:"change"}),action:{target:e.options.id,type:e.getActionsDropdown().getValue()}}}))))}),[])}}]);return t}(p.EventEmitter);var Y;var z=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),"cache",new g.Cache.MemoryCache);n.setEventNamespace("BX.Landing.UI.FormSettingsPanel.FieldRules.FieldActionPanel");n.subscribeFromOptions(y.fetchEventsFromOptions(e));if(g.Type.isPlainObject(e.style)){g.Dom.style(n.getLayout(),e.style)}return n}babelHelpers.createClass(t,[{key:"getLayout",value:function e(){var t=this;return this.cache.remember("layout",(function(){return g.Tag.render(Y||(Y=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-field-action-panel">\n\t\t\t\t\t','\n\t\t\t\t\t<div class="landing-ui-rule-field-action-panel-decoration">\n\t\t\t\t\t\t<div class="landing-ui-rule-field-action-panel-decoration-v-line"></div>\n\t\t\t\t\t\t<div class="landing-ui-rule-field-action-panel-decoration-h-line"></div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t'])),t.getActionPanel().getLayout())}))}},{key:"getActionPanel",value:function e(){var t=this;return this.cache.remember("actionPanel",(function(){return new f.ActionPanel({left:[{id:"addCondition",text:v.Loc.getMessage("LANDING_RULE_GROUP_ADD_FIELD_CONDITION"),onClick:function e(){t.emit("onAddCondition")}}]})}))}}]);return t}(p.EventEmitter);var W,Z,K,q;var J=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));n.setEventNamespace("BX.Landing.UI.Panel.FormSettingsPanel.Content.FieldRules.RuleGroup");n.subscribeFromOptions(y.fetchEventsFromOptions(e));n.setLayoutClass("landing-ui-rule-group");var i=n.getLayout();g.Dom.clean(i);g.Dom.append(n.getHeaderLayout(),i);g.Dom.append(n.getBodyLayout(),i);g.Dom.append(n.getFooterLayout(),i);if(g.Type.isArrayFilled(n.options.data.list)){var r=n.options.data.list.filter((function(e){var t=n.getField(e.condition.target);var i=n.getField(e.action.target);return t&&i}));if(n.getTypeId()===h.TYPE_0){var o=r.reduce((function(e,t){var n=t.condition,i=n.target,r=n.operation,o=n.value;if(!g.Type.isArray(e["".concat(i).concat(r).concat(o)])){e["".concat(i).concat(r).concat(o)]=[]}e["".concat(i).concat(r).concat(o)].push(t);return e}),{});Object.values(o).forEach((function(e,t){var i=babelHelpers.slicedToArray(e,1),r=i[0];if(g.Type.isPlainObject(r)){var o=n.getField(r.condition.target);var a=new G({enableHeader:t===0,typeId:n.getTypeId(),fields:n.options.fields,onChange:function e(){return n.emit("onChange")},conditions:[new O({dictionary:n.options.dictionary,fields:n.options.fields,id:o.id,title:o.label,color:O.Colors.blue,onRemove:function e(){n.onConditionFieldRemove(a)}}),new R({dictionary:n.options.dictionary,fields:n.options.fields,removable:false,data:e[0].condition})],expressions:e.map((function(e){var t=n.getField(e.action.target);return new O({id:t.id,title:t.label,removable:true,color:O.Colors.green,actionsLabel:v.Loc.getMessage("LANDING_RULE_EXPRESSION_FIELD_ACTION_LABEL"),actionsList:[{name:v.Loc.getMessage("LANDING_RULE_EXPRESSION_FIELD_ACTION_SHOW_LABEL"),value:"show"},{name:v.Loc.getMessage("LANDING_RULE_EXPRESSION_FIELD_ACTION_HIDE_LABEL"),value:"hide"}],actionsValue:e.action.type})}))});n.addEntry(a)}}))}if(n.getTypeId()===h.TYPE_1||n.getTypeId()===h.TYPE_2){var a=new G({enableHeader:true,typeId:n.getTypeId(),fields:n.options.fields,onChange:function e(){return n.emit("onChange")}});var s=r.reduce((function(e,t){var n=t.condition.target;if(!g.Type.isArray(e[n])){e[n]=[]}e[n].push(t);return e}),{});Object.values(s).forEach((function(e){var t=babelHelpers.slicedToArray(e,1),i=t[0];if(g.Type.isPlainObject(i)){var r=n.getField(i.condition.target);var o=n.getTypeId()===h.TYPE_2&&r.multiple||n.getTypeId()===h.TYPE_1;a.addCondition(new O({dictionary:n.options.dictionary,fields:n.options.fields,id:r.id,title:r.label,color:O.Colors.blue,onRemove:function e(){n.onConditionFieldRemove(a)}}));var s=e.reduce((function(e,t){e["".concat(t.condition.operation).concat(t.condition.value)]=t;return e}),{});Object.values(s).forEach((function(e){a.addCondition(new R({dictionary:n.options.dictionary,fields:n.options.fields,removable:o,data:e.condition}))}));a.addCondition(new z({style:{display:o?null:"none"},onAddCondition:function e(){n.onAddFieldCondition(new p.BaseEvent({data:{entry:a,target:r.id}}))}}))}}));var l=Object.values(r).reduce((function(e,t){var n=t.action,i=n.target,r=n.type;e["".concat(i).concat(r)]=t;return e}),{});Object.values(l).forEach((function(e){var t=n.getField(e.action.target);var i=new O({id:t.id,title:t.label,removable:true,color:O.Colors.green,actionsLabel:v.Loc.getMessage("LANDING_RULE_EXPRESSION_FIELD_ACTION_LABEL"),actionsList:[{name:v.Loc.getMessage("LANDING_RULE_EXPRESSION_FIELD_ACTION_SHOW_LABEL"),value:"show"},{name:v.Loc.getMessage("LANDING_RULE_EXPRESSION_FIELD_ACTION_HIDE_LABEL"),value:"hide"}],actionsValue:e.action.type});a.addExpression(i)}));n.addEntry(a)}}return n}babelHelpers.createClass(t,[{key:"getEntries",value:function e(){return this.cache.remember("entries",(function(){return[]}))}},{key:"setEntries",value:function e(t){this.cache.set("entries",t)}},{key:"addEntry",value:function e(t){var n=this;if(t){var i=this.getEntries();if(!i.includes(t)){t.subscribe("onChange",(function(){return n.emit("onChange")}));i.push(t);g.Dom.append(t.getLayout(),this.getBodyLayout());this.emit("onChange")}}}},{key:"getHeaderLayout",value:function e(){var t=this;return this.cache.remember("headerLayout",(function(){return g.Tag.render(W||(W=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-group-header">\n\t\t\t\t\t',"\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),t.getHeaderTitleLayout(),t.getRemoveButtonLayout())}))}},{key:"getHeaderTitleLayout",value:function e(){var t=this;return this.cache.remember("headerTitleLayout",(function(){var e=v.Loc.getMessage("LANDING_FIELDS_RULES_TYPE_".concat(t.getTypeId()+1));return g.Tag.render(Z||(Z=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-group-header-title">',"</div>\n\t\t\t"])),e)}))}},{key:"getRemoveButtonLayout",value:function e(){var t=this;return this.cache.remember("removeButtonLayout",(function(){var e=new s.IconButton({type:s.IconButton.Types.remove,onClick:t.onRemoveClick.bind(t),title:v.Loc.getMessage("LANDING_RULE_GROUP_REMOVE_BUTTON_TITLE"),style:{marginLeft:"auto"}});return e.getLayout()}))}},{key:"onRemoveClick",value:function e(){g.Dom.remove(this.getLayout());this.emit("onRemove");this.emit("onChange")}},{key:"getBodyLayout",value:function e(){return this.cache.remember("bodyLayout",(function(){return g.Tag.render(K||(K=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-group-body"></div>\n\t\t\t'])))}))}},{key:"getFooterLayout",value:function e(){var t=this;return this.cache.remember("footerLayout",(function(){return g.Tag.render(q||(q=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-rule-group-footer">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t"])),t.getFooterActionPanel().getLayout())}))}},{key:"getFooterActionPanel",value:function e(){var t=this;return this.cache.remember("footerActionPanel",(function(){return new f.ActionPanel({left:[{id:"selectField",text:v.Loc.getMessage("LANDING_RULE_ENTRY_ADD_FIELD_LABEL"),onClick:t.onAddFieldClick.bind(t)}]})}))}},{key:"onAddFieldClick",value:function e(t){var n=this.getFieldsListMenu();n.getPopupWindow().setBindElement(t.currentTarget);n.show()}},{key:"getFieldsListMenu",value:function e(){var t=this;return this.cache.remember("fieldsMenu",(function(){return new window.top.BX.Main.Menu({maxHeight:205,items:t.options.fields.map((function(e){return{id:e.id,text:e.label,onclick:function n(){t.onFieldsListMenuItemClick(e);t.getFieldsListMenu().close()}}})),autoHide:true})}))}},{key:"getDefaultValueState",value:function e(t){var n=this.options.fields.find((function(e){return String(e.id)===String(t)}));if(n){var i=this.options.dictionary.deps.condition.operations.filter((function(e){return(!g.Type.isArrayFilled(e.fieldTypes)||e.fieldTypes.includes(n.type))&&(!g.Type.isArrayFilled(e.excludeFieldTypes)||g.Type.isArrayFilled(e.excludeFieldTypes)&&!e.excludeFieldTypes.includes(n.type))}));if(g.Type.isArrayFilled(i)){return i[0].id}}return"="}},{key:"onAddFieldCondition",value:function e(t){var n=t.getData(),i=n.target,r=n.entry;r.addCondition(new R({dictionary:this.options.dictionary,fields:this.options.fields,removable:true,data:{target:i,operation:this.getDefaultValueState(i),value:null}}))}},{key:"onConditionFieldRemove",value:function e(t){var n=t.conditions.filter((function(e){return e instanceof O}));if(n.length===1){var i=this.getEntries().filter((function(e){return t!==e}));this.setEntries(i);g.Dom.remove(t.getLayout())}}},{key:"onFieldsListMenuItemClick",value:function e(t){var n=this;if(this.getTypeId()===h.TYPE_0){var i=this.getEntries().length===0;var r=new G({enableHeader:i,typeId:this.getTypeId(),fields:this.options.fields,conditions:[new O({dictionary:this.options.dictionary,fields:this.options.fields,id:t.id,title:t.label,color:O.Colors.blue,onRemove:function e(){n.onConditionFieldRemove(r)}}),new R({dictionary:this.options.dictionary,fields:this.options.fields,removable:false,data:{target:t.id,operation:this.getDefaultValueState(t.id),value:null}})],onChange:function e(){return n.emit("onChange")}});this.addEntry(r)}if(this.getTypeId()===h.TYPE_1||this.getTypeId()===h.TYPE_2){var o=this.getTypeId()===h.TYPE_2&&t.multiple||this.getTypeId()===h.TYPE_1;var a=[new O({dictionary:this.options.dictionary,fields:this.options.fields,id:t.id,title:t.label,color:O.Colors.blue,onRemove:function e(){n.onConditionFieldRemove(n.getEntries()[0])}}),new R({dictionary:this.options.dictionary,fields:this.options.fields,removable:o,data:{target:t.id,operation:this.getDefaultValueState(t.id),value:null}})];if(this.getTypeId()===h.TYPE_1||this.getTypeId()===h.TYPE_2){a.push(new z({style:{display:o?null:"none"},onAddCondition:function e(){n.onAddFieldCondition(new p.BaseEvent({data:{entry:n.getEntries()[0],target:t.id}}))}}))}var s=this.getEntries(),l=babelHelpers.slicedToArray(s,1),u=l[0];if(u){a.forEach((function(e){u.addCondition(e)}))}else{var d=new G({enableHeader:true,typeId:this.getTypeId(),fields:this.options.fields,conditions:a,onChange:function e(){return n.emit("onChange")}});this.addEntry(d)}}}},{key:"getId",value:function e(){if(!g.Type.isNil(this.options.data.id)){return this.options.data.id}return 0}},{key:"getTypeId",value:function e(){return g.Text.toNumber(this.options.data.typeId)}},{key:"getLogic",value:function e(){return this.getTypeId()===h.TYPE_2?"and":"or"}},{key:"getValue",value:function e(){var t=this.getEntries().reduce((function(e,t){return[].concat(babelHelpers.toConsumableArray(e),babelHelpers.toConsumableArray(t.getValue()))}),[]);return{id:this.getId(),typeId:this.getTypeId(),logic:this.getLogic(),list:t}}},{key:"getField",value:function e(t){return this.options.fields.find((function(e){return String(e.id)===String(t)}))}}]);return t}(a.BaseField);function Q(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ee=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));n.setEventNamespace("BX.Landing.UI.Panel.FormSettingsPanel.FieldsRulesContent");n.addItem(n.getHeader());if(!g.Type.isArrayFilled(n.options.formOptions.data.dependencies)){n.addItem(n.getRuleTypeField())}else{n.addItem(n.getRulesForm());n.addItem(n.getActionPanel())}return n}babelHelpers.createClass(t,[{key:"getHeader",value:function e(){return this.cache.remember("headerCard",(function(){return new n.HeaderCard({title:g.Loc.getMessage("LANDING_FIELDS_RULES_TITLE")})}))}},{key:"getRulesForm",value:function e(){var t=this;return this.cache.remember("rulesForm",(function(){return new r.FormSettingsForm({selector:"dependencies",description:null,fields:t.options.formOptions.data.dependencies.map((function(e){return new J({dictionary:t.options.dictionary,fields:t.getFormFields(),data:e,onRemove:t.onRuleGroupRemove.bind(t)})}))})}))}},{key:"getActionPanel",value:function e(){var t=this;return this.cache.remember("actionPanel",(function(){return new f.ActionPanel({left:[{text:g.Loc.getMessage("LANDING_FIELDS_ADD_NEW_RULE_LINK_LABEL"),onClick:t.onAddRuleClick.bind(t)}]})}))}},{key:"onAddRuleClick",value:function e(){this.insertBefore(this.getRuleTypeField(),this.getActionPanel());this.items.remove(this.getActionPanel());g.Dom.remove(this.getActionPanel().getLayout());this.getActionPanel().unsubscribe("onChange",this.onChange)}},{key:"getRuleTypeField",value:function e(){var t=this;return this.cache.remember("ruleTypeField",(function(){return new i.RadioButtonField({selector:"rules-type",items:Object.entries(h).map((function(e){var n=babelHelpers.slicedToArray(e,2),i=n[1];return{id:"ruleType".concat(i),icon:"landing-ui-rules-type".concat(i+1,"-icon"),title:g.Loc.getMessage("LANDING_FIELDS_RULES_TYPE_".concat(i+1)),button:{text:g.Loc.getMessage("LANDING_FIELDS_RULES_TYPE_BUTTON"),onClick:t.onCreateRuleButtonClick.bind(t,{type:i})}}}))})}))}},{key:"getFormFields",value:function e(){var t=this;var n=function(){if(!g.Type.isPlainObject(t.options.dictionary.deps.field)||!g.Type.isArrayFilled(t.options.dictionary.deps.field.disallowed)){return null}return t.options.dictionary.deps.field.disallowed}();return this.options.formOptions.data.fields.filter((function(e){return!g.Type.isArrayFilled(n)||!n.includes(e.type)&&(!g.Type.isPlainObject(e.content)||n.includes(e.content.type))}))}},{key:"onCreateRuleButtonClick",value:function e(t){var n=t.type;this.clear();var i=this.getHeader();i.setBottomMargin(false);this.addItem(i);var r=this.getRulesForm();r.addField(new J({dictionary:this.options.dictionary,fields:this.getFormFields(),data:{id:0,typeId:n,list:[],logic:n===h.TYPE_2?"and":"or"},onRemove:this.onRuleGroupRemove.bind(this)}));this.addItem(r);this.addItem(this.getActionPanel())}},{key:"onRuleGroupRemove",value:function e(t){this.onChange(t);this.getRulesForm().removeField(t.getTarget());t.getTarget().unsubscribe("onChange",this.onChange)}},{key:"onChange",value:function e(t){this.emit("onChange",$($({},t.getData()),{},{skipPrepare:true}))}},{key:"valueReducer",value:function e(t){return{dependencies:Object.values(t).filter((function(e){return g.Type.isArrayFilled(e.list)}))}}}]);return t}(t.ContentWrapper);e.default=ee})(this.BX.Landing.Ui.Panel.Formsettingspanel.Content=this.BX.Landing.Ui.Panel.Formsettingspanel.Content||{},BX.Landing.UI.Panel,BX.Landing.UI.Card,BX.Landing.UI.Field,BX.Landing.UI.Form,BX,BX.Landing.UI.Field,BX.Landing.UI.Component,BX.Main,BX.Landing,BX.Landing.UI.Field,BX,BX.Event,BX,BX.Landing.UI.Component,BX.Landing.UI.Component,BX.Landing);
//# sourceMappingURL=fields-rules.bundle.map.js